<template>
  <div class="container">
     <live-pusher
      class="pusher"
      url="rtmp://lovekaka.lovekaka.cn/akk/test"
      mode="RTC"
      @statechange="statechange"
      :device-position="deviceposition"
      :orientation="orientation"
      :beauty="beauty"
      :whiteness="whiteness"
      :enable-mic="mic"
      :enable-camera="camera"
      style="width: 100%; height: 100%"
      waiting-image="http://akk028wkf.oss-cn-beijing.aliyuncs.com/app/dynamic/20180828/NELF-845359_full.jpg"
    >
      <div class="control" v-if="!isClose"> 
        <div class="top">
          <div class="left">
            <img src="../../../../static/assets/icon/new-home-icon1.png" alt="">
            <div>
              <p class="overflow">喜欢吃面的...</p>
              <p>美妆</p>
            </div>
          </div>
          <div class="right">
            <p class="peoplenum">当前人数1.9W</p>
            <p class="more" @click="moreOperation">...</p>
          </div>
          <!-- 右上角 -->
          <div class="righttop" v-if="showMoreOperation">
            <p>关闭声音</p>
            <p>关闭画面</p>
            <p @click.stop="closeLive">关闭直播</p>
            <div class="cc" @click.stop="closeRightTop"></div>
          </div>
        </div>
        <div class="equipment" v-if="!isStart">
          <div class="item">{{mic?'麦克风已开启':'麦克风未开启'}}</div>
          <div class="item">{{camera?'摄像头已开启':'摄像头未开启'}}</div>
        </div>
        <div v-if="!isStart" class="seting" @click="setLive">{{mic&&camera?'开始':'设置手机'}}</div>
        <div class="rignt">
          <p class="set"><img src="../../../../static/assets/icon/new-home-icon1.png" alt=""></p>
          <p class="product" @click="relationProduct"><img src="../../../../static/assets/icon/i22.png" alt=""></p>
        </div>
        <!-- 弹幕 -->
        <div class="danmu" v-if="isStart">
          <p class="comment" v-for="(item,index) in commentList" :key="index">{{item.name}}:{{item.comment}}</p>
        </div>
      </div>
      <!-- 关闭直播 -->
      <div class="close" v-if="isClose">
        <p class="p1">本次直播中断3次</p>
        <p class="p2"><span class="time">08:35:11 </span> <span class="time2">直播时长00:26:12</span></p>
        <p class="p2"><span class="time">08:35:11 </span> <span class="time2">直播时长00:26:12</span></p>
        <p class="p2"><span class="time">08:35:11 </span> <span class="time2">直播时长00:26:12</span></p>
        <p class="p3">合计时长：01:41:33</p>
        <div class="seting closebtn" @click="setLive">关闭</div>
      </div>
    </live-pusher>
    <!-- 关联商品 -->
     <div class="bankCardBox" v-if="showPopup">
      <div class="bankCardCont">
        <div class="tit">关联商品(4)
          <span class="editbtn">编辑</span>
        </div>
        <div class="prod" v-for="item in productList" :key="item.id">
          <div class="pro-item">
            <img class="proimg" :src="item.img" alt="">
            <div>
              <p class="pname">{{item.name}}</p>
              <p class="pricebox">
                <span class="price">￥{{item.price}}</span>
                <span class="oprice">￥{{item.originalPrice}}</span>
              </p>
            </div>
          </div>
          <div class="share">分享</div>
        </div>
      </div>
      <div class="zz" @click="zzClick"></div>
    </div>
    
  </div>
</template>

<script>
export default {
  data () {
    return {
      deviceposition: 'front', // 摄像头方向  front:前置 ，back:后置
      orientation: 'vertical', // 画面方向  vertical：竖直，horizontal：水平
      beauty: 9, // 美颜等级0-9
      whiteness: 9, // 美白等级 0-9
      mic: false, // 开启或关闭麦克风
      camera: true, // 开启摄像头
      isStart: false, // 是否已开始直播
      commentList: [
        {
          id: 1,
          name: '有趣的人',
          comment: '喜欢'
        },
        {
          id: 2,
          name: '有趣的人',
          comment: '喜欢这个眉笔好看,OMG，买它，买它，买它'
        },
        {
          id: 3,
          name: '有趣的人',
          comment: '喜欢这个眉笔好看'
        }
      ],
      showPopup: false, // 关联商品弹窗
      productList: [
        {
          id: 1,
          img: 'http://img3.imgtn.bdimg.com/it/u=4092387650,1688197925&fm=11&gp=0.jpg',
          name: '家居装饰花式简装展示用',
          price: 99,
          originalPrice: 199
        },
        {
          id: 2,
          img: 'http://img3.imgtn.bdimg.com/it/u=4092387650,1688197925&fm=11&gp=0.jpg',
          name: '家居装饰花式简装展示用',
          price: 99,
          originalPrice: 199
        },
        {
          id: 3,
          img: 'http://img3.imgtn.bdimg.com/it/u=4092387650,1688197925&fm=11&gp=0.jpg',
          name: '家居装饰花式简装展示用',
          price: 99,
          originalPrice: 199
        },
        {
          id: 4,
          img: 'http://img3.imgtn.bdimg.com/it/u=4092387650,1688197925&fm=11&gp=0.jpg',
          name: '家居装饰花式简装展示用',
          price: 99,
          originalPrice: 199
        }
      ],
      showMoreOperation: false, // 是否显示更多操作，右上角
      isClose: false
    }
  },
  methods: {
    statechange (e) {
      console.log('live-pusher code:', e.target.code)
    },
    setLive () {
      // 如果麦克风和摄像头都开启，则显示文字为“开始”并执行操作，否则显示文字为“设置手机”，执行打开麦克风操作
      if (this.mic && this.camera) {
        this.isStart = true
      } else {
        this.mic = true
      }
    },
    // 关联商品
    relationProduct () {
      this.showPopup = true
    },
    zzClick () {
      this.showPopup = false
    },
    closeRightTop () {
      this.showMoreOperation = false
    },
    moreOperation () {
      this.showMoreOperation = true
    },
    closeLive () {
      this.isClose = true
      this.showMoreOperation = false
    }
  }
}
</script>

<style lang="scss" scoped>
@import 'static/styles/color.scss';
.seting{
  width: 130px;
  height: 45px;
  background:rgba($color: #000000, $alpha: 0.5);
  border-radius: 23px;
  color: #ffffff;
  text-align: center;
  line-height: 45px;
  position: absolute;
  bottom: 25px;
  left: calc(50% - 65px);
}
.control{
  width: 100%;
  height: 100%;
  position: relative;
  
  .equipment{
    position: absolute;
    bottom: 150px;
    left: calc(50% - 40px);
    .item{
      width: 80px;
      height: 25px;
      background:rgba($color: #000000, $alpha: 0.5);
      color: #ffffff;
      font-size: 10px;
      border-radius: 13px;
      text-align: center;
      line-height: 25px;
      margin: auto;
      margin-top: 20px;
    }
   
  }
  .rignt{
    position: absolute;
    bottom: 25px;
    right: 15px;
    p{
      width: 30px;
      height: 30px;
      background:rgba($color: #000000, $alpha: 0.5);
      border-radius: 50%;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top: 10px;
      img{
        width: 21px;
        height: 21px;
      }
    }
  }
  .top{
    display: flex;
    justify-content: space-between;
    margin: 0 15px;
    position: relative;
    .left{
      width: 110px;
      height: 35px;
      background:rgba($color: #000000, $alpha: 0.5);
      border-radius: 23px;
      color: #ffffff;
      display: flex;
      font-size: 11px;
      padding: 3px;
      .overflow{
        width: 80px;
        overflow: hidden;
        text-overflow:ellipsis;
        white-space: nowrap;
      }
      img{
        width: 25px;
        height: 25px;
        margin-right: 2px;
      }
    }
    .right{
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      .peoplenum{
        color: #ffffff;
        background:rgba($color: #000000, $alpha: 0.5);
        border-radius: 23px;
        text-align: center;
        height: 20px;
        font-size: 10px;
        padding: 0 5px;
        line-height: 20px;
        margin-bottom: 10px;
      } 
      .more{
        width: 30px;
        height: 15px;
        color: #ffffff;
        background:rgba($color: #000000, $alpha: 0.5);
        border-radius: 23px;
        text-align: center;
        line-height: 6px;
      }
     
    }
    .righttop{
      position: absolute;
      right: 0px;
      top: 53px;
      color: #ffffff;
      background: rgba($color: #000000, $alpha: .5);
      width: 65px;
      border-radius: 5px;
      padding: 1px 10px;
      z-index: 5;
      p{
        font-size: 11px;
        margin: 10px 0;
      }
    }
    .cc{
      position: fixed;
      z-index: 2;
      top: 0;
      left: 0;
      width: 79%;
      height: 70%;
      margin-top: 50px;
    }
  }
  .danmu{
    position: absolute;
    bottom: 25px;
    left: 15px;
    .comment{
      background:rgba($color: #000000, $alpha: 0.5);
      color: #ffffff;
      font-size: 13px;
      border-radius: 10px;
      max-width: 200px;
      margin-top:10px;
      padding: 5px;
    }
  }
}
.bankCardBox {
  position: absolute;
  bottom: 0;
  .bankCardCont {
    position: fixed;
    bottom: 0;
    z-index: 5;
    width: 100%;
    padding: 10px 15px;
    background: #fff;
    .tit {
      text-align: center;
      margin: 12px 0;
      font-size: 14px;
      position: relative;
      .editbtn{
        position: absolute;
        right: 15px;
        color: #4673F7;
      }
    }
    .prod{
      display: flex;
      justify-content: space-between;
      align-items: center;
      .pro-item{
        display: flex;
        margin-top: 10px;
        .proimg{
          width: 53px;
          height: 53px;
          margin-right: 3px;
        }
        .pname{
          font-size: 13px;
        }
        .pricebox{
          .price{
            font-size: 15px;
            color: #e35a58;
            margin-right: 3px;
          }
          .oprice{
            color: #999999;
            font-size: 11px;
            text-decoration: line-through;
          }
        }
      }
      .share{
        width: 50px;
        height: 25px;
        border: 1px solid #4673f7;
        border-radius: 13px;
        color: #4673F7;
        font-size: 12px;
        text-align: center;
        line-height: 25px;
      }
    }
  }
}
.zz {
  position: fixed;
  z-index: 2;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background-color: #000000;
  opacity: 0.3;
}
.close{
  padding-top: 120px;
  background: rgba($color: #000000, $alpha: .5);
  width: 100%;
  height: 100%;
  p{
    text-align: center;
    color: #ffffff;
  }
  .p1,.p3{
    font-size: 18px;
    margin: 30px 0;
  }
  .p2{
    margin: 10px 0;
  }
  .closebtn{
    background: rgba($color: #000000, $alpha: .5);
  }

}

</style>